/**
 * Copyright (C), 2019-2020, 宇信融汇
 * FileName: Person
 * Author:   xbliu
 * Date:     2020/7/9 8:38
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * xbliu           修改时间           版本号              描述
 */
package c_008.collection;

/**
 * @Classname Person
 * @Description TODO
 * @Date 2020/7/9 8:38
 * @Created by xbliu
 */
public class Person  {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Person person = (Person) o;

        if (age != person.age) return false;
        return name != null ? name.equals(person.name) : person.name == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + age;
        return result;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }


//    @Override
//    public int compareTo(Object o) {
//        Person p = (Person) o;
//        if (p.name.length() > this.name.length()) {
//            return 1;
//        } else if (p.name.length() < this.name.length()) {
//            return -1;
//        } else {
//            return 0;
//        }
//
//    }
}
